%%
%% Author: suau
%% 15/03/19
%%

\PassOptionsToPackage{table,dvipsnames,svgnames}{xcolor}
\documentclass[11pt, twoside, a4paper]{report}
\usepackage[inner = 30mm, outer = 20mm,  top = 30mm, bottom = 20mm, headheight = 13.6pt]{geometry}
\usepackage{tikz}
\usepackage[pdfpagelayout=TwoPageRight]{hyperref}
\usepackage[export]{adjustbox}
%\usepackage{showframe}
\hypersetup{colorlinks=true, linktoc=all, allcolors=green!30!black,}

\usepackage{pgfplots}
\pgfplotsset{compat=1.13}


\usepgfplotslibrary{external}
\tikzexternalize[
    prefix={},
    only named,
]

%\pgfkeys{/pgf/images/include external/.code=\includegraphics{#1}}

% Make the 'export as png' a seperate style, with default density 200
\tikzset{
    export as png/.style={
        external/system call/.add={}{
            && convert -density #1 -transparent white "\image.pdf" "\image.png"%
            && rm "\image.log" "\image.dpth" "\image.pdf"
        },
    },
    export as png/.default={200},
}

\begin{document}

    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{non_oriented_neumann_graph}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray] (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill]     (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill]     (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill]     (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill]     (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill]     (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill]     (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray] (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \draw[very thick] (1) -- (2);
            \draw[very thick] (2) -- (3);
            \draw[very thick, dashed] (3) -- (4);
            \draw[very thick] (4) -- (5);
            \draw[very thick] (5) -- (6);
            \draw[very thick, draw=gray] (6) -- (7);
        \end{tikzpicture}
    \end{figure}

    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{non_oriented_dirichlet_graph}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray] (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill]     (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill]     (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill]     (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill]     (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill]     (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill]     (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray] (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \path (1) edge[very thick, loop left, min distance=3cm] (1);
            \draw[very thick] (1) -- (2);
            \draw[very thick] (2) -- (3);
            \draw[very thick, dashed] (3) -- (4);
            \draw[very thick] (4) -- (5);
            \draw[very thick] (5) -- (6);
            \draw[very thick, draw=gray] (6) -- (7);
            \path (6) edge[very thick, loop right, min distance=3cm] (6);
        \end{tikzpicture}
    \end{figure}


    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{non_oriented_neumann_graph_numbered}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray]              (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill, label={0}]       (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill, label={1}]       (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill, label={2}]       (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-3$}] (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-2$}] (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-1$}] (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray]              (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \draw[very thick] (1) -- node[below] {0} (2);
            \draw[very thick] (2) -- node[below] {1} (3);
            \draw[very thick, dashed] (3) -- (4);
            \draw[very thick] (4) -- node[below] {$N_c-2$} (5);
            \draw[very thick] (5) -- node[below] {$N_c-1$} (6);
            \draw[very thick, draw=gray] (6) -- (7);
        \end{tikzpicture}
    \end{figure}


    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{non_oriented_dirichlet_graph_numbered}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray]              (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill, label={0}]       (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill, label={1}]       (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill, label={2}]       (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-3$}] (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-2$}] (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-1$}] (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray]              (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \path (1) edge[very thick, loop left, min distance=3cm] node[right] {0} (1);
            \draw[very thick] (1) -- node[below] {1} (2);
            \draw[very thick] (2) -- node[below] {2} (3);
            \draw[very thick, dashed] (3) -- (4);
            \draw[very thick] (4) -- node[below] {$N_c-2$} (5);
            \draw[very thick] (5) -- node[below] {$N_c-1$} (6);
            \draw[very thick, draw=gray] (6) -- (7);
            \path (6) edge[very thick, loop right, min distance=3cm] node[left] {$N_c$} (6);
        \end{tikzpicture}
    \end{figure}



    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{oriented_neumann_graph_numbered}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray]              (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill, label={0}]       (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill, label={1}]       (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill, label={2}]       (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-3$}] (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-2$}] (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-1$}] (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray]              (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \draw[very thick, ->] (1) -- node[below] {0} (2);
            \draw[very thick, ->] (2) -- node[below] {1} (3);
            \draw[very thick, dashed, ->] (3) -- (4);
            \draw[very thick, ->] (4) -- node[below] {$N_c-2$} (5);
            \draw[very thick, ->] (5) -- node[below] {$N_c-1$} (6);
            \draw[very thick, draw=gray] (6) -- (7);
        \end{tikzpicture}
    \end{figure}


    \begin{figure}
        \tikzset{export as png}
        \tikzsetnextfilename{oriented_dirichlet_graph_numbered}
        \begin{tikzpicture}
            \node[shape=circle, draw=gray, fill=gray]              (0) at (0,  0) {};
            \node[shape=circle, draw=black, fill, label={0}]       (1) at (3,  0) {};
            \node[shape=circle, draw=black, fill, label={1}]       (2) at (6,  0) {};
            \node[shape=circle, draw=black, fill, label={2}]       (3) at (9,  0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-3$}] (4) at (15, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-2$}] (5) at (18, 0) {};
            \node[shape=circle, draw=black, fill, label={$N_c-1$}] (6) at (21, 0) {};
            \node[shape=circle, draw=gray, fill=gray]              (7) at (24, 0) {};

            \draw[very thick, draw=gray] (0) -- (1);
            \path (1) edge[very thick, loop left, min distance=3cm, ->] node[right] {0} (1);
            \draw[very thick, ->] (1) -- node[below] {1} (2);
            \draw[very thick, ->] (2) -- node[below] {2} (3);
            \draw[very thick, dashed, ->] (3) -- (4);
            \draw[very thick, ->] (4) -- node[below] {$N_c-1$} (5);
            \draw[very thick, ->] (5) -- node[below] {$N_c$} (6);
            \draw[very thick, draw=gray] (6) -- (7);
            \path (6) edge[very thick, loop right, min distance=3cm, ->] node[left] {$N_c+1$} (6);
        \end{tikzpicture}
    \end{figure}

\end{document}
